//
//  StoreVC.m
//  AppNew
//
//  Created by 华伟 on 2019/6/22.
//  Copyright © 2019 华伟. All rights reserved.
//

#import "StoreVC.h"
#import "StoreCell.h"
@interface StoreVC ()<UITableViewDelegate, UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *storeTbl;
@property (weak, nonatomic) IBOutlet UIButton *search;
@property (weak, nonatomic) IBOutlet UITextField *searchTextView;
@property(nonatomic, strong)UIView *maskView;
@end

@implementation StoreVC
- (IBAction)searchAction:(UIButton *)sender {
}

- (void)passCoin{
    
}
- (void)hideMask{
    [UIView animateWithDuration:0.8 animations:^{
        self->_maskView.opaque = 0;
    }];
    _maskView.hidden = true;
}
- (void)showMask{

    if(!_maskView){
        _maskView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
        _maskView.backgroundColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.5];
        [self.view addSubview:_maskView];
        UITapGestureRecognizer *gesTure = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideMask)];
        [_maskView addGestureRecognizer:gesTure];
        
        UIView *bottomView = [UIView new];
        bottomView.frame = CGRectMake(0, ScreenHeight - 160, ScreenWidth, 160);
        bottomView.backgroundColor = [UIColor whiteColor];
        [_maskView addSubview:bottomView];
        
        UIView *bottomView1 = [UIView new];
        bottomView1.frame = CGRectMake(10, 20, ScreenWidth - 20, 50);
        bottomView1.layer.borderWidth = 1;
        bottomView1.layer.borderColor = [UIColor colorFromHexRGB:@"f5f5f5"].CGColor;
        [bottomView addSubview:bottomView1];
        
        UILabel *label = [UILabel new];
        label.frame = CGRectMake(10, 0, 60, 50);
        label.textColor = [UIColor colorFromHexRGB:@"333333"];
        label.font = [UIFont systemFontOfSize:15.f];
        [bottomView addSubview:label];
        
        UITextField *textf = [UITextField new];
        textf.frame = CGRectMake(label.t_right, 0, bottomView1.t_width-label.t_right, 50);
        textf.placeholder =  @"请输入转币的数量";
        [bottomView1 addSubview:textf];
        
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
        [btn setTitle:@"转币" forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        btn.backgroundColor = BaseColor;
        [btn addTarget:self action:@selector(passCoin) forControlEvents:UIControlEventTouchUpInside];
        btn.frame = CGRectMake(10, bottomView1.t_bottom +20, ScreenWidth - 20, 50);
        [bottomView addSubview:btn];
        
        
        
    }else{
        _maskView.hidden = false;
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"商铺";
    [_storeTbl registerNib:[UINib nibWithNibName:@"StoreCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"storeCell"];
    _storeTbl.tableFooterView = [UIView new];
    _storeTbl.showsVerticalScrollIndicator = false;
    _storeTbl.separatorStyle = UITableViewCellSelectionStyleNone;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 80.f;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    StoreCell *cell = [tableView dequeueReusableCellWithIdentifier:@"storeCell" forIndexPath:indexPath];
    if (!cell) {
        cell = [StoreCell new];
    }
    
    return  cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:true];
    [self showMask];
}


@end
